Make the bash script a bit less clumsy on close. #4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When the app closes, the script kills off all inotifywait commands. Well, if you
have have inotifywait commands running on your machine, those get killed! Not
cool. Now, we can just kill all of the processes owned by the script and no one
else.
But app close isn't the only thing addressed. The other thing tackled in here is
an issue where if inotify notices changes faster than the go can recompile, then
you can get into a case where an older version of the app can be running while a
new version may not run because of a conflicting port. The problem was that the
kill command was focusing on the compiled app; but the compilation takes a
little time. So if Go hasn't finished compiling the app, then there's nothing to
kill and Go just compiles the app and runs it. Instead of targetting the running
go program, the script now attempts to kill "go run" and the Go app, if that app
has already started"
Lastly, I added some documentation to the functions in the file. I used the
Google shell style guide[1] in lieu of not knowing what else to use. The nice
part is that the global variables required for each function are documented.
[1] - https://google-styleguide.googlecode.com/svn/trunk/shell.xml